<?php
// PDOStatement类，PDO预处理类。
$dsn = 'mysql:host=localhost;dbname=phpcode20;charset=utf8';
$pdo = new PDO($dsn, 'root', '123456');

//$sql = 'insert into users (name) values (:name)';
//$stmt = $pdo->prepare($sql); // 预处理，提前编译
//$result = $stmt->execute([':name' => '赵六六']);
//var_dump($result);
$id = 5;
$sql = 'select * from users where id > :id';
$stmt = $pdo->prepare($sql);
$result = $stmt->execute([':id' => $id]);
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));


